package com.example.firstopengl.programs;

import android.content.Context;
import android.opengl.GLES20;

import com.example.firstopengl.R;

import javax.microedition.khronos.opengles.GL;

/**
 * Created by liqian-ps on 2017/7/6.
 */

public class ColorShaderProgram extends  ShaderProgram{
    private int uMatrixLocation;
    private int aPositionLocation;
    private int aColorLocation;
    public ColorShaderProgram(Context context) {
        super(context, R.raw.simple_vertex_shader, R.raw.simple_fragment_shader);

        uMatrixLocation = GLES20.glGetUniformLocation(programId, U_MATRIX);
        aPositionLocation = GLES20.glGetAttribLocation(programId,A_POSITION);
        aColorLocation = GLES20.glGetAttribLocation(programId, A_COLOR);
    }

    public void setUniforms(float[] matrix){
        GLES20.glUniformMatrix4fv(uMatrixLocation, 1, false, matrix, 0);
    }

    public int getPositionLocation(){
        return aPositionLocation;
    }
    public int getColorLocation(){
        return aColorLocation;
    }
}
